package pdfsetter.gui;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.List;

import javax.swing.JComponent;

@SuppressWarnings("serial")
public class PDFImageComponent extends JComponent {
        
        private List<Image> pages;
        private int pageNo;
        
        public PDFImageComponent(List<Image> pages, Dimension dim) {
                super();
                pageNo = 0;
                this.pages = pages;
                setSize(dim);
                setPreferredSize(dim);
                setMinimumSize(dim);
        }
        
        public void changePage(int pageNo) {
                this.pageNo = pageNo;
                repaint();
        }
        
        @Override
        public void paint(Graphics g) {
                if(pages.get(pageNo) instanceof BufferedImage) {
                        BufferedImage bi = (BufferedImage) pages.get(pageNo);
                        g.drawImage(bi, 0, 0, getWidth(), getHeight(), null);
                }
                else {
                        // TODO
                }
        }
}
